package com.example.perftool2;

import android.content.Context;
import android.provider.Settings;

public class SettingsUtils {

    private static final String PID = "perf_pid";
    private static final String CPU = "perf_cpu";
    private static final String IDLE_CPU = "perf_idle";
    private static int mPid;

    public static int getPid() {
        return mPid;
    }

    public static String getPidFromSettings(Context context) {
        return Settings.Global.getString(context.getContentResolver(), PID);
    }

    public static void updatePid(Context context, int pid) {
        mPid = pid;
        Settings.Global.putString(context.getContentResolver(), PID, "" + pid);
    }

    public static String getCpu(Context context) {
        return Settings.Global.getString(context.getContentResolver(), CPU);
    }

    public static String getCpu(Context context, int pid) {
        return Settings.Global.getString(context.getContentResolver(), CPU + "_" + pid);
    }

    public static String getIdleCpu(Context context) {
        return Settings.Global.getString(context.getContentResolver(), IDLE_CPU);
    }

    public static String[] getPerfApps(Context context) {
        String[] apps;
        String s = Settings.Global.getString(context.getContentResolver(), "perf_apps");
        apps = s.split(" ");
        return apps;
    }

    public static String getMemPercent(Context context, int pid) {
        return Settings.Global.getString(context.getContentResolver(),  "perf_mem_" + pid);
    }
}
